﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq.Expressions;
using System.Xml.Linq;
using xycn.Base;

namespace xycn.IDbService
{
    /// <summary>
    /// 数据库操作接口
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface IDbService
    {
        #region 添加数据
        /// <summary>
        /// 添加一条数据,并返回添加成功后的主键ID
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Result<string> AddItem<T>(T entity) where T : class, new();

        /// <summary>
        /// 添加多条数据 返回影响行数
        /// </summary>
        /// <param name="entitys"></param>
        /// <returns></returns>
        Result<int> AddItems<T>(List<T> entitys) where T : class, new();

        #endregion

        #region 删除

        /// <summary>
        /// 删除数据 返回影响行数
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        Result<int> DeleteItem<T>(Expression<Func<T, bool>> expression) where T : class, new();

        /// <summary>
        /// 删除数据 返回影响行数
        /// </summary>
        /// <param name="queryWhere"></param>
        /// <returns></returns>
        Result<int> DeleteItemByDic<T>(Dictionary<string, object> queryWhere) where T : class, new();

        #endregion

        #region 查询
        /// <summary>
        /// 查询所有数据
        /// </summary>
        /// <returns></returns>
        Result<List<T>> GetList<T>(Expression<Func<T, bool>> expression, string orderby = "") where T : class, new();

        /// <summary>
        /// 查询所有数据
        /// </summary>
        /// <returns></returns>
        List<T> GetListByDic<T>(Dictionary<string, object> queryWhere) where T : class, new();

        /// <summary>
        /// 分页查询数据
        /// </summary>
        /// <param name="expression">linq查询表达式</param>
        /// <param name="page">页数</param>
        /// <param name="limit">当前页数条数</param>
        /// <param name="totalNum">总数</param>
        /// <param name="orderby">排序</param>
        /// <returns></returns>
        Result<List<T>> GetListByPage<T>(Expression<Func<T, bool>> expression, int page, int limit, ref int totalNum, string orderby = "") where T : class, new();


        /// <summary>
        /// 查询Count
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="expression"></param>
        /// <returns></returns>
        Result<int> GetCount<T>(Expression<Func<T, bool>> expression = null) where T : class, new();

        /// <summary>
        /// 获取一条数据
        /// </summary>
        /// <returns></returns>
        Result<T> GetOne<T>(Expression<Func<T, bool>> expression) where T : class, new();

        #endregion

        #region 修改数据

        /// <summary>
        /// 修改多列数据 返回影响行数
        /// </summary>
        /// <param name="upfields"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        Result<int> UpdateFields<T>(Expression<Func<T, T>> upfields, Expression<Func<T, bool>> where) where T : class, new();

        /// <summary>
        /// 修改多列数据 返回影响行数
        /// </summary>
        /// <param name="upfields"></param>
        /// <param name="where"></param>
        /// <param name="ignoreColumns">忽略的列 it => new { it.CreateTime,it.TestId }</param>
        /// <returns></returns>
        Result<int> UpdateFieldsIgnore<T>(Expression<Func<T, T>> upfields, Expression<Func<T, bool>> where) where T : class, new();

        /// <summary>
        /// 修改多列数据 返回影响行数
        /// </summary>
        /// <param name="upfields"></param>
        /// <param name="where"></param>
        /// <param name="onlyColumns">只修改的列 it => new { it.CreateTime,it.TestId }</param>
        /// <returns></returns>
        Result<int> UpdateFieldsOnly<T>(Expression<Func<T, T>> upfields, Expression<Func<T, bool>> where, Expression<Func<T, object>> onlyColumns) where T : class, new();


        /// <summary>
        /// 修改一列数据 返回影响行数
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="where"></param>
        /// <returns></returns>
        Result<int> UpdateOneField<T>(Expression<Func<T, bool>> columns, Expression<Func<T, bool>> where) where T : class, new();

        #endregion

        #region 原始Sql支持

        /// <summary>
        /// 数据查询GetDataTable("select * from `order` where @id>0  or name=@name", new { id = 1, name = "2" });
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数  new { id = 1, name = "2" }</param>
        /// <returns></returns>
        DataTable GetDataTable(string sql, object parameters = null);

        /// <summary>
        /// 数据查询 GetDataSetAll("select * from `order` where @id>0  or name=@name", new { id = 1, name = "2" });
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数  new { id = 1, name = "2" }</param>
        /// <returns></returns>
        DataSet GetDataSetAll(string sql, object parameters = null);

        /// <summary>
        /// 数据查询
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数  new { id = 1, name = "2" }</param>
        /// <returns></returns>
        object GetScalar(string sql, object parameters = null);

        /// <summary>
        /// 数据查询
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数  new { id = 1, name = "2" }</param>
        /// <returns></returns>
        string GetString(string sql, object parameters = null);

        /// <summary>
        /// 执行Sql
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数  new { id = 1, name = "2" }</param>
        /// <returns></returns>
        int ExecuteCommand(string sql, object parameters = null);

        /// <summary>
        /// 根据Sql查询
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="parameters">参数  new { id = 1, name = "2" }</param>
        /// <returns></returns>
        List<T> SqlQuery<T>(string sql, object parameters = null) where T : class, new();

        #endregion

        #region 事务
        /// <summary>
        /// 开始事务
        /// </summary>
        void BeginTran();
        /// <summary>
        /// 回滚事务
        /// </summary>
        void RollbackTran();
        /// <summary>
        /// 结束事务
        /// </summary>
        void CommitTran();
        #endregion

        #region 关联查询

        /// <summary>
        /// 分组获取数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="where"></param>
        /// <param name="groupby"></param>
        /// <returns></returns>
        Result<List<T>> GroupBy<T>(Expression<Func<T, bool>> where, Expression<Func<T, object>> groupby) where T : class, new();


        /// <summary>
        /// 2张表 关联查询 使用示例 
        ///     _dbhelper.GetList<Members, Members2, MemberView>((a, b) => true, "a.kid=b.kid", JoinType.Left,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        Result<List<T3>> GetList<T, T2, T3>(Expression<Func<T, T2, bool>> joinExpression, string sqlJoinWhere, JoinType joinTypes, Expression<Func<T, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();

        /// <summary>
        /// 3张表 关联查询 使用示例 几张表关联就应该有 几对 joinwhere 和 sqlJoinType，数量必须一致
        ///     List<string> joinwhere = new List<string>();
        ///         sqlwhere.Add("a.kid=b.kid2 and a.GroupId=b.kid2");
        ///         sqlwhere.Add("b.kid2=c.kid3");
        ///     List<JoinType> sqlJoinType = new List<JoinType>();
        ///         sqlJoinType.Add(JoinType.Left);
        ///         sqlJoinType.Add(JoinType.Right);
        ///      说明：   
        ///     _dbhelper.GetList<Members, Members2, Members3, MemberView>((a, b, c) => true, joinwhere, sqlJoinType,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        ///     
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">第三张表</typeparam>
        /// <typeparam name="T4">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        /// <returns></returns>
        Result<List<T4>> GetList<T, T2, T3, T4>(Expression<Func<T, T2, T3, bool>> joinExpression, List<string> sqlJoinWhere, List<JoinType> joinTypes, Expression<Func<T, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();

        /// <summary>
        /// 4张表 关联查询 使用示例 几张表关联就应该有 几对 joinwhere 和 sqlJoinType，数量必须一致
        ///     List<string> joinwhere = new List<string>();
        ///         sqlwhere.Add("a.kid=b.kid2 and a.GroupId=b.kid2");
        ///         sqlwhere.Add("b.kid2=c.kid3");
        ///     List<JoinType> sqlJoinType = new List<JoinType>();
        ///         sqlJoinType.Add(JoinType.Left);
        ///         sqlJoinType.Add(JoinType.Right);
        ///      说明：   
        ///     _dbhelper.GetList<Members, Members2, Members3, MemberView>((a, b, c) => true, joinwhere, sqlJoinType,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        ///     
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">第三张表</typeparam>
        /// <typeparam name="T4">第四张表</typeparam>
        /// <typeparam name="T5">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        /// <returns></returns>
        Result<List<T5>> GetList<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, bool>> joinExpression, List<string> sqlJoinWhere, List<JoinType> joinTypes, Expression<Func<T, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();


        /// <summary>
        /// 5张表 关联查询 使用示例 几张表关联就应该有 几对 joinwhere 和 sqlJoinType，数量必须一致
        ///     List<string> joinwhere = new List<string>();
        ///         sqlwhere.Add("a.kid=b.kid2 and a.GroupId=b.kid2");
        ///         sqlwhere.Add("b.kid2=c.kid3");
        ///     List<JoinType> sqlJoinType = new List<JoinType>();
        ///         sqlJoinType.Add(JoinType.Left);
        ///         sqlJoinType.Add(JoinType.Right);
        ///      说明：   
        ///     _dbhelper.GetList<Members, Members2, Members3, MemberView>((a, b, c) => true, joinwhere, sqlJoinType,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        ///     
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">第三张表</typeparam>
        /// <typeparam name="T4">第四张表</typeparam>
        /// <typeparam name="T5">第五张表</typeparam>
        /// <typeparam name="T6">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        /// <returns></returns>
        Result<List<T6>> GetList<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression, List<string> sqlJoinWhere, List<JoinType> joinTypes, Expression<Func<T, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();

        /// <summary>
        /// 6张表 关联查询 使用示例 几张表关联就应该有 几对 joinwhere 和 sqlJoinType，数量必须一致
        ///     List<string> joinwhere = new List<string>();
        ///         sqlwhere.Add("a.kid=b.kid2 and a.GroupId=b.kid2");
        ///         sqlwhere.Add("b.kid2=c.kid3");
        ///     List<JoinType> sqlJoinType = new List<JoinType>();
        ///         sqlJoinType.Add(JoinType.Left);
        ///         sqlJoinType.Add(JoinType.Right);
        ///      说明：   
        ///     _dbhelper.GetList<Members, Members2, Members3, MemberView>((a, b, c) => true, joinwhere, sqlJoinType,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        ///     
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">第三张表</typeparam>
        /// <typeparam name="T4">第四张表</typeparam>
        /// <typeparam name="T5">第五张表</typeparam>
        /// <typeparam name="T6">第六张表</typeparam>
        /// <typeparam name="T7">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        /// <returns></returns>
        Result<List<T7>> GetList<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression, List<string> sqlJoinWhere, List<JoinType> joinTypes, Expression<Func<T, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();

        #endregion

        #region 关联查询 扩展方式

        /// <summary>
        /// 2张表 关联查询 使用示例 
        ///     _dbhelper.GetList<Members, Members2, MemberView>((a, b) => true, "a.kid=b.kid", JoinType.Left,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        Result<List<T3>> GetList<T, T2, T3>(Expression<Func<T, T2, bool>> joinExpression, string sqlJoinWhere, JoinType joinTypes, Expression<Func<T, T2, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();

        /// <summary>
        /// 3张表 关联查询 使用示例 几张表关联就应该有 几对 joinwhere 和 sqlJoinType，数量必须一致
        ///     List<string> joinwhere = new List<string>();
        ///         sqlwhere.Add("a.kid=b.kid2 and a.GroupId=b.kid2");
        ///         sqlwhere.Add("b.kid2=c.kid3");
        ///     List<JoinType> sqlJoinType = new List<JoinType>();
        ///         sqlJoinType.Add(JoinType.Left);
        ///         sqlJoinType.Add(JoinType.Right);
        ///      说明：   
        ///     _dbhelper.GetList<Members, Members2, Members3, MemberView>((a, b, c) => true, joinwhere, sqlJoinType,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        ///     
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">第三张表</typeparam>
        /// <typeparam name="T4">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        /// <returns></returns>
        Result<List<T4>> GetList<T, T2, T3, T4>(Expression<Func<T, T2, T3, bool>> joinExpression, List<string> sqlJoinWhere, List<JoinType> joinTypes, Expression<Func<T, T2, T3, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();

        /// <summary>
        /// 4张表 关联查询 使用示例 几张表关联就应该有 几对 joinwhere 和 sqlJoinType，数量必须一致
        ///     List<string> joinwhere = new List<string>();
        ///         sqlwhere.Add("a.kid=b.kid2 and a.GroupId=b.kid2");
        ///         sqlwhere.Add("b.kid2=c.kid3");
        ///     List<JoinType> sqlJoinType = new List<JoinType>();
        ///         sqlJoinType.Add(JoinType.Left);
        ///         sqlJoinType.Add(JoinType.Right);
        ///      说明：   
        ///     _dbhelper.GetList<Members, Members2, Members3, MemberView>((a, b, c) => true, joinwhere, sqlJoinType,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        ///     
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">第三张表</typeparam>
        /// <typeparam name="T4">第四张表</typeparam>
        /// <typeparam name="T5">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        /// <returns></returns>
        Result<List<T5>> GetList<T, T2, T3, T4, T5>(Expression<Func<T, T2, T3, T4, bool>> joinExpression, List<string> sqlJoinWhere, List<JoinType> joinTypes, Expression<Func<T, T2, T3, T4, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();


        /// <summary>
        /// 5张表 关联查询 使用示例 几张表关联就应该有 几对 joinwhere 和 sqlJoinType，数量必须一致
        ///     List<string> joinwhere = new List<string>();
        ///         sqlwhere.Add("a.kid=b.kid2 and a.GroupId=b.kid2");
        ///         sqlwhere.Add("b.kid2=c.kid3");
        ///     List<JoinType> sqlJoinType = new List<JoinType>();
        ///         sqlJoinType.Add(JoinType.Left);
        ///         sqlJoinType.Add(JoinType.Right);
        ///      说明：   
        ///     _dbhelper.GetList<Members, Members2, Members3, MemberView>((a, b, c) => true, joinwhere, sqlJoinType,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        ///     
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">第三张表</typeparam>
        /// <typeparam name="T4">第四张表</typeparam>
        /// <typeparam name="T5">第五张表</typeparam>
        /// <typeparam name="T6">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        /// <returns></returns>
        Result<List<T6>> GetList<T, T2, T3, T4, T5, T6>(Expression<Func<T, T2, T3, T4, T5, bool>> joinExpression, List<string> sqlJoinWhere, List<JoinType> joinTypes, Expression<Func<T, T2, T3, T4, T5, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();

        /// <summary>
        /// 6张表 关联查询 使用示例 几张表关联就应该有 几对 joinwhere 和 sqlJoinType，数量必须一致
        ///     List<string> joinwhere = new List<string>();
        ///         sqlwhere.Add("a.kid=b.kid2 and a.GroupId=b.kid2");
        ///         sqlwhere.Add("b.kid2=c.kid3");
        ///     List<JoinType> sqlJoinType = new List<JoinType>();
        ///         sqlJoinType.Add(JoinType.Left);
        ///         sqlJoinType.Add(JoinType.Right);
        ///      说明：   
        ///     _dbhelper.GetList<Members, Members2, Members3, MemberView>((a, b, c) => true, joinwhere, sqlJoinType,  a=>a.WxNickName.Contains("张三"), a => a.KID, OrderType.Desc);
        ///     
        /// </summary>
        /// <typeparam name="T">第一张表</typeparam>
        /// <typeparam name="T2">第二张表</typeparam>
        /// <typeparam name="T3">第三张表</typeparam>
        /// <typeparam name="T4">第四张表</typeparam>
        /// <typeparam name="T5">第五张表</typeparam>
        /// <typeparam name="T6">第六张表</typeparam>
        /// <typeparam name="T7">返回的数据视图</typeparam>
        /// <param name="joinExpression">关联名</param>
        /// <param name="sqlJoinWhere">格式 a.kid=b.kid and 1=1 </param>
        /// <param name="joinTypes">枚举类型</param>
        /// <param name="where">where条件 Lambda 表达式</param>
        /// <param name="orderby">排序字段 Lambda 表达式</param>
        /// <param name="orderType">排序类型 0ASC 1DESC</param>
        /// <param name="rowCount">总数</param>
        /// <param name="resFields">返回字段列表 a.*,b.*,a.kid as aakid </param>
        /// <param name="page">分页 默认1</param>
        /// <param name="limit">每页条数 默认20 </param>
        /// <returns></returns>
        Result<List<T7>> GetList<T, T2, T3, T4, T5, T6, T7>(Expression<Func<T, T2, T3, T4, T5, T6, bool>> joinExpression, List<string> sqlJoinWhere, List<JoinType> joinTypes, Expression<Func<T, T2, T3, T4, T5, T6, bool>> where
            , Expression<Func<T, object>> orderby, OrderType orderType, ref int rowCount, string resFields = "", int page = 1, int limit = 20) where T : class, new();

        #endregion
    }
}
